﻿package plugins.mstandio.testing {

	import flash.display.Sprite;
	import flash.events.Event;	
	import flash.events.TextEvent;
	import flash.display.Stage;
	import flash.display.StageScaleMode;
	
	import flash.text.TextField;
	import plugins.mstandio.utils.combobox.ComboBox;
	import plugins.mstandio.utils.combobox.ComboBoxEvent;
	import plugins.mstandio.utils.combobox.ComboBoxStyle;
	
	/**
	 * Testing ground for ComboBox utility
	 * @author mstandio
	 */
	public class ComboBox_tester extends Sprite{
		
		private var txt:TextField;
		
		private var comb:plugins.mstandio.utils.combobox.ComboBox;
		private var array:Array;		
		private var style:ComboBoxStyle;
		
		public function ComboBox_tester(){
			this.addEventListener(Event.ADDED_TO_STAGE, stageReady);			
		}
		
		private function stageReady(e:Event):void {			
			this.removeEventListener(Event.ADDED_TO_STAGE, stageReady);							
			stage.scaleMode = StageScaleMode.NO_SCALE;
			
			
			this.txt = new TextField();
			this.addChild(txt);
			txt.x = -250;
			
			this.graphics.beginFill(0xffbbaa);
			this.graphics.drawRect(0, 0, 600, 600);
			this.graphics.endFill();			
						
			
			this.array = new Array( {label:"dupa", costam:"fff"}, {label:"orzechowy fart", costam:"fffaasss"} ,{label:"addss", costam:"echy"});
									
			
			this.style = new ComboBoxStyle();
			this.style.opensUp = true;			
			this.style.elementSpacing = 0;
			//this.style.fontBold = false;
			//this.style.elementBorder = true;
			//this.style.elementHeight = 23;
			this.style.fontSize = 25;
			//this.style.elementAlpha = 0.5;
			//this.style.mainElementAlpha = 0.5;
			this.style.elementBorder = false;
			this.style.mainElementBorder = true;
			//this.style.openingSpeed = 0.3;
			this.style.initiallyBlank = true;
			
			this.comb = new ComboBox(this.array,this.style);
			this.comb.x = this.comb.y = 200;
			this.addChild(this.comb);						
			
			//this.comb.setStyle(this.style);
			
			this.addEventListener(ComboBoxEvent.LABEL_CHANGED, labelChanged);
						
			//this.comb.setSelected("addss");												
			//this.comb.disable();
			//this.comb.enable();			
		}		
		
		private function labelChanged(e:ComboBoxEvent):void {			
			this.txt.text = "label : " + e.info.label;
		}	
	}	
}